/*
 * TuteView.java
 */

package tute;
import cartas.*;
import java.util.Calendar;
import java.util.LinkedList;
import jugadores.*;
import brisca.*;
import java.awt.*;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.util.ArrayList;


import java.util.GregorianCalendar;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;

/**
 * The application's main frame.
 */
public class TuteView extends FrameView {

    public TuteView(SingleFrameApplication app) {
        super(app);
        long tiempo1,tiempo2;
        
        
        
        not_played=false;
        card_index=0;
       /* mazo temp = new mazo();
        Naipe temp2 = new Naipe();
        
        long start = System.nanoTime();


       CombinationHelper test  = new CombinationHelper();
       long time = System.nanoTime();
       System.out.println(time-start);
        mazo Algarete = new mazo();
        Algarete.llenarMazo();
        Algarete.barajar();
       ArrayList<mazo> test2 = test.getCombinations(Algarete, 3);
      /* for(int i =0;i<test2.size();i++){
           temp = test2.get(i);
           
           for (int j=0;j<temp.getSize();j++){
                temp2 = temp.getNaipe(j);
               System.out.print(temp2.nombreFlor()+" ");
              System.out.print(temp2.numero());
              System.out.print(" ");
           }
           System.out.println();
           
           
       }
       
       
       System.out.println(test2.size());
       mazo lamano = test2.get(0);
       
       for (int t=0;t<lamano.getSize();t++){
           
           System.out.println(lamano.getNaipe(t).nombreFlor()+"  "+ lamano.getNaipe(t).numero());
       }
       double[] probability = test.CardVsCombinations(lamano, test2, "basto");
       for(int g=0;g<probability.length;g++){
           System.out.println(probability[g]);
       }*/
        
        initComponents();
        
        
      
        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
        
          
    }
 
    public void paintImages(LinkedList<String> the_list, String palo, LinkedList<String> mesa) {
        
      Image vida = Toolkit.getDefaultToolkit().getImage(palo);
      vidaCard.setIcon(new javax.swing.ImageIcon(palo));
      Image portada = Toolkit.getDefaultToolkit().getImage("images/portada.jpg"); 
            
      compCard1.setIcon(new javax.swing.ImageIcon("images/portada.jpg"));
      compCard2.setIcon(new javax.swing.ImageIcon("images/portada.jpg"));
      compCard3.setIcon(new javax.swing.ImageIcon("images/portada.jpg"));
      
       
      if(mesa.size()==1){
          Image jugada = Toolkit.getDefaultToolkit().getImage(mesa.get(0));
              played1.setIcon(new javax.swing.ImageIcon(mesa.get(0)));
      }
       
       
       if(the_list.size()==3){
        String url1 = the_list.get(0);
        String url2 = the_list.get(1);
        String url3 = the_list.get(2);
   
      humanCard1.setIcon(new javax.swing.ImageIcon(url1));
      humanCard2.setIcon(new javax.swing.ImageIcon(url2));
      humanCard3.setIcon(new javax.swing.ImageIcon(url3));
        }
        else
            if(the_list.size()==2){
        String url1 = the_list.get(0);
        String url2 = the_list.get(1);
      Image carta1 = Toolkit.getDefaultToolkit().getImage(url1);
      Image carta2 = Toolkit.getDefaultToolkit().getImage(url2);
      humanCard1.setIcon(new javax.swing.ImageIcon(url1));
      humanCard2.setIcon(new javax.swing.ImageIcon(url2));
            }
            else{
            String url1 = the_list.get(0);
            Image carta1 = Toolkit.getDefaultToolkit().getImage(url1);
            humanCard1.setIcon(new javax.swing.ImageIcon(url1));
            }
      
           
       
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = TuteApp.getApplication().getMainFrame();
            aboutBox = new TuteAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        TuteApp.getApplication().show(aboutBox);
    }

   

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        label1 = new java.awt.Label();
        panel4 = new java.awt.Panel();
        panel3 = new java.awt.Panel();
        label2 = new java.awt.Label();
        verde = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        compCard1 = new javax.swing.JLabel();
        compCard2 = new javax.swing.JLabel();
        compCard3 = new javax.swing.JLabel();
        humanCard1 = new javax.swing.JLabel();
        humanCard2 = new javax.swing.JLabel();
        humanCard3 = new javax.swing.JLabel();
        played1 = new javax.swing.JLabel();
        vidaCard = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jPanel3 = new javax.swing.JPanel();

        mainPanel.setName("mainPanel"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(tute.TuteApp.class).getContext().getResourceMap(TuteView.class);
        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        label1.setName("playerstats"); // NOI18N
        label1.setText(resourceMap.getString("playerstats.text")); // NOI18N

        panel4.setBackground(resourceMap.getColor("panel4.background")); // NOI18N
        panel4.setName("panel4"); // NOI18N

        org.jdesktop.layout.GroupLayout panel4Layout = new org.jdesktop.layout.GroupLayout(panel4);
        panel4.setLayout(panel4Layout);
        panel4Layout.setHorizontalGroup(
            panel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 308, Short.MAX_VALUE)
        );
        panel4Layout.setVerticalGroup(
            panel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 217, Short.MAX_VALUE)
        );

        panel3.setBackground(resourceMap.getColor("panel3.background")); // NOI18N
        panel3.setName("panel3"); // NOI18N

        org.jdesktop.layout.GroupLayout panel3Layout = new org.jdesktop.layout.GroupLayout(panel3);
        panel3.setLayout(panel3Layout);
        panel3Layout.setHorizontalGroup(
            panel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 296, Short.MAX_VALUE)
        );
        panel3Layout.setVerticalGroup(
            panel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 193, Short.MAX_VALUE)
        );

        label2.setName("computerstats"); // NOI18N
        label2.setText(resourceMap.getString("computerstats.text")); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(panel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(label1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(panel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(label2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(50, Short.MAX_VALUE)
                .add(label2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(panel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(label1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(panel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(39, 39, 39))
        );

        verde.setBackground(resourceMap.getColor("verde.background")); // NOI18N
        verde.setName("verde"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        compCard1.setText(resourceMap.getString("compCard1.text")); // NOI18N
        compCard1.setName("compCard1"); // NOI18N

        compCard2.setText(resourceMap.getString("compCard2.text")); // NOI18N
        compCard2.setName("compCard2"); // NOI18N

        compCard3.setText(resourceMap.getString("compCard3.text")); // NOI18N
        compCard3.setName("compCard3"); // NOI18N

        humanCard1.setText(resourceMap.getString("humanCard1.text")); // NOI18N
        humanCard1.setName("humanCard1"); // NOI18N
        humanCard1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                humanCard1MouseClicked(evt);
            }
        });

        humanCard2.setText(resourceMap.getString("humanCard2.text")); // NOI18N
        humanCard2.setName("humanCard2"); // NOI18N
        humanCard2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                humanCard2MouseClicked(evt);
            }
        });

        humanCard3.setText(resourceMap.getString("humanCard3.text")); // NOI18N
        humanCard3.setName("humanCard3"); // NOI18N
        humanCard3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                humanCard3MouseClicked(evt);
            }
        });

        played1.setText(resourceMap.getString("played1.text")); // NOI18N
        played1.setName("played1"); // NOI18N

        vidaCard.setText(resourceMap.getString("vidaCard.text")); // NOI18N
        vidaCard.setName("vidaCard"); // NOI18N

        org.jdesktop.layout.GroupLayout verdeLayout = new org.jdesktop.layout.GroupLayout(verde);
        verde.setLayout(verdeLayout);
        verdeLayout.setHorizontalGroup(
            verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(verdeLayout.createSequentialGroup()
                .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(verdeLayout.createSequentialGroup()
                        .add(152, 152, 152)
                        .add(humanCard1))
                    .add(verdeLayout.createSequentialGroup()
                        .add(110, 110, 110)
                        .add(jLabel7)))
                .add(115, 115, 115)
                .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(humanCard2)
                    .add(jLabel8))
                .add(77, 77, 77)
                .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(verdeLayout.createSequentialGroup()
                        .add(jLabel9)
                        .addContainerGap())
                    .add(verdeLayout.createSequentialGroup()
                        .add(humanCard3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                        .add(280, 280, 280))))
            .add(verdeLayout.createSequentialGroup()
                .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(verdeLayout.createSequentialGroup()
                        .add(114, 114, 114)
                        .add(compCard1))
                    .add(verdeLayout.createSequentialGroup()
                        .add(29, 29, 29)
                        .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel4)
                            .add(vidaCard))))
                .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(verdeLayout.createSequentialGroup()
                        .add(92, 92, 92)
                        .add(compCard2))
                    .add(verdeLayout.createSequentialGroup()
                        .add(27, 27, 27)
                        .add(jLabel5)))
                .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(verdeLayout.createSequentialGroup()
                        .add(228, 228, 228)
                        .add(played1)
                        .add(89, 89, 89))
                    .add(verdeLayout.createSequentialGroup()
                        .add(69, 69, 69)
                        .add(jLabel6))
                    .add(verdeLayout.createSequentialGroup()
                        .add(108, 108, 108)
                        .add(compCard3)))
                .add(339, 339, 339))
        );
        verdeLayout.setVerticalGroup(
            verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(verdeLayout.createSequentialGroup()
                .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(verdeLayout.createSequentialGroup()
                        .add(67, 67, 67)
                        .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(compCard1)
                            .add(compCard2)
                            .add(compCard3))
                        .add(33, 33, 33)
                        .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel4)
                            .add(jLabel5)
                            .add(jLabel6))
                        .add(168, 168, 168)
                        .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(humanCard1)
                            .add(humanCard2)
                            .add(humanCard3)))
                    .add(verdeLayout.createSequentialGroup()
                        .add(240, 240, 240)
                        .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(vidaCard)
                            .add(played1))))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 37, Short.MAX_VALUE)
                .add(verdeLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel9)
                    .add(jLabel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel7))
                .add(150, 150, 150))
        );

        org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup()
                .add(12, 12, 12)
                .add(verde, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 702, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(258, 258, 258)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(verde, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(32, Short.MAX_VALUE))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(tute.TuteApp.class).getContext().getActionMap(TuteView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        org.jdesktop.layout.GroupLayout statusPanelLayout = new org.jdesktop.layout.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1320, Short.MAX_VALUE)
            .add(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(statusMessageLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 1124, Short.MAX_VALUE)
                .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelLayout.createSequentialGroup()
                .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(statusMessageLabel)
                    .add(statusAnimationLabel)
                    .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(3, 3, 3))
        );

        jPanel3.setName("jPanel3"); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 100, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 100, Short.MAX_VALUE)
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void humanCard1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_humanCard1MouseClicked
        // TODO add your handling code here:
        card_index=0;
        not_played=false;
    }//GEN-LAST:event_humanCard1MouseClicked

    private void humanCard2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_humanCard2MouseClicked
        // TODO add your handling code here:
        
        card_index=1;
        not_played=false;
    }//GEN-LAST:event_humanCard2MouseClicked

    private void humanCard3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_humanCard3MouseClicked
        // TODO add your handling code here:
        card_index=2;
        not_played=false;
    }//GEN-LAST:event_humanCard3MouseClicked
public void startGame(){
    
    Brisca elJueguito = new Brisca(this);
   Thread t = new Thread(elJueguito);
   t.start();
     
    
}
   
public int jugar(){
     not_played=true;
 
     while(not_played==true){
     }
   
     return card_index;
}

   
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel compCard1;
    private javax.swing.JLabel compCard2;
    private javax.swing.JLabel compCard3;
    private javax.swing.JLabel humanCard1;
    private javax.swing.JLabel humanCard2;
    private javax.swing.JLabel humanCard3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private java.awt.Label label1;
    private java.awt.Label label2;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private java.awt.Panel panel3;
    private java.awt.Panel panel4;
    private javax.swing.JLabel played1;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JPanel verde;
    private javax.swing.JLabel vidaCard;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private boolean not_played;
    private JDialog aboutBox;
    int card_index;
   
    
   // Image imagen1 = Toolkit.getDefaultToolkit().getImage("images/basto/12.jpg");
    //Image imagen2 = Toolkit.getDefaultToolkit().getImage("images/copa/3.jpg");
    //Image imagen3 = Toolkit.getDefaultToolkit().getImage("images/basto/11.jpg");
    

   
    
}
